import request from "@/api/request";

const rootUrl = "/system/sys"
const accountUrl = `${rootUrl}/account`
const roleUrl = `${rootUrl}/role`
const postUrl = `${rootUrl}/post`


/**
 * 获取用户列表
 * @param query
 * @returns {AxiosPromise}
 */
export function accountList(query) {
    return request({
        url: `${accountUrl}/pageList`,
        method: 'get',
        params: query
    })
}

/**
 * 保存账号
 * @param account
 * @returns {Promise<AxiosResponse<any>>}
 */
export function save(account) {
    return request.post(`${accountUrl}`, account)
}

/**
 * 根据ID修改
 * @param account
 * @returns {Promise<AxiosResponse<any>>}
 */
export function updateById(account) {
    return request.put(`${accountUrl}`, account)
}

/**
 * 根据ID删除
 * @param id
 * @returns {Promise<AxiosResponse<any>>}
 */
export function removeById(id) {
    return request.delete(`${accountUrl}?idList=${id}`)
}

/**
 *  重置密码
 * @param params
 * @returns {Promise<AxiosResponse<any>>}
 */
export function resetPassword(params) {
    return request.put(`${accountUrl}/resetPassword`, params)
}

/**
 * 更新密码
 * @param params
 * @returns {Promise<AxiosResponse<any>>}
 */
export function updatePassword(params) {
    return request.put(`${accountUrl}/password`, params)
}

/**
 * 设置人脸识别信息
 * @returns {Promise<AxiosResponse<any>>}
 */
export function setFaceId(params){
    return request.put(`${accountUrl}/faceId`, params)
}

export function allRole() {
    return request.get(`${roleUrl}/allRole`)
}

export function allPost() {
    return request.get(`${postUrl}/allPost`)
}
